//
// Created by Zhangwj on 2023/9/26.
//

#include "BlockNode.h"

std::unique_ptr<BlockNode> BlockNode::BlockParser(Parser &parser) {
    // Block → '{' { BlockItem } '}'
    std::unique_ptr<BlockNode> blockNode = std::make_unique<BlockNode>();
    if (parser.getLexType(0) == LexType::LBRACE) {
        parser.next();
    }
    while (parser.getLexType(0) != LexType::RBRACE) {
        blockNode->BlockItems.push_back(BlockItemNode::BlockItemParser(parser));
    }
    if (parser.getLexType(0) == LexType::RBRACE) {
        parser.next();
    }
    return blockNode;
}
